const Controller = require("../core/base_controller");

/**
 * @Controller 用户模块
 */
class UserController extends Controller {
  /**
   * @summary 查询用户
   * @router post /user/list
   * @response 200 response
   */
  async list() {
    const { ctx, service } = this;
    const result = await service.user.getUserList();
    if (result) {
      this.success(result);
    } else {
      this.fail("获取失败");
    }
  }

  /**
   * @summary 创建用户
   * @router post /user/create
   * @Request body createUserReq
   * @response 200 response
   * @Deprecated //未完成或不启用
   */
  async create() {
    const { ctx, service } = this;
    // 参数验证
    ctx.validate(ctx.rule.createUserReq, ctx.request.body);
    ctx.body = await service.user.createUser();
  }
}

module.exports = UserController;
